﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Ryder_US_Website.BUS;
using Ryder_US_Website.Utils;

namespace Ryder_US_Website.Presentation.Admin
{
    public partial class Info : System.Web.UI.Page
    {
        private String[] arr_role = new String[2] { "Quản trị", "Nhân viên" };
        RUS_User user = new RUS_User();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["RUS_User"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            user = (RUS_User)Session["RUS_User"];

            if (!IsPostBack)
            {
                lbLoaiNV.Text = arr_role[user.User_role].ToString();
                lbTenDangNhap.Text = user.User_username;
            }

        }

        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            RUS_User kq = new RUS_User();
            try
            {
               user.User_password = txtMatKhau.Text;
               kq = UserBUS.Update(user.User_username, user.User_password, user.User_role, user.User_ID);
                   
            }
            catch (Exception ex)
            {
                Response.Write(UtilHelpers.ShowMessage(ex.Message));
            }

            if (user.User_ID.Equals(kq.User_ID))
            {
                Response.Redirect("Home.aspx");
            }
            else
            {
                Response.Write(UtilHelpers.ShowMessage("Cập nhật không thành công"));
            }
        }

        protected void btnHuy_Click(object sender, EventArgs e)
        {
            Response.Redirect("Home.aspx");
        }
    }
}
